import { axiosInstance } from "..";

function getDueTo() {
  return new Promise((resolve, reject) => {
    const username = localStorage.getItem("username")?.toString().trim();
    axiosInstance()
      .post("/material/query/getduetowork", { username })
      .then(
        (res: any) => {
          resolve(res);
        },
        (error: any) => {
          reject(error);
        }
      );
  });
}

function searchFlowList(param: string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/material/query/searchFlowList", { param })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function searchFlowCount(param: string) {
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/material/query/searchFlowCount", { param })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function searchFlowDetail(docid:string){
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/material/query/searchFlowDetail", { docid })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

function getDocInfo(data:string){
  return new Promise((reslove,reject)=>{
    axiosInstance()
    .post("/material/query/getDocInfo",{data})
    .then(
      (res:any)=>{
        reslove(res)
      },
      (err:any)=>{
        reject(err)
      }
    )
  })
}

function getDocCount(data:string){
  return new Promise((reslove,reject)=>{
    axiosInstance()
    .post("/material/query/getDocCount",{data})
    .then(
      (res:any)=>{
        reslove(res)
      },
      (err:any)=>{
        reject(err)
      }
    )
  })
}

export { getDueTo, searchFlowList,searchFlowCount,searchFlowDetail,getDocInfo,getDocCount };
